package org.qpcr.community.project.web;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hswebframework.ezorm.rdb.mapping.defaults.SaveResult;
import org.hswebframework.web.authorization.annotation.Authorize;
import org.hswebframework.web.authorization.annotation.Resource;
import org.hswebframework.web.authorization.annotation.SaveAction;
import org.hswebframework.web.crud.web.reactive.ReactiveServiceCrudController;
import org.qpcr.community.project.model.entity.CarrierUsageRecordInstanceEntity;
import org.qpcr.community.project.service.LocalCarrierUsageRecordInstanceService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping( {"/project/carrier-usage-record", "/project/carrier/usage/record"})
@Authorize
@Resource(id = "carrier-usage-record", name = "载体使用记录")
@Slf4j
@Tag(name = "载体使用记录接口")
@RequiredArgsConstructor
public class CarrierUsageRecordController implements
    ReactiveServiceCrudController<CarrierUsageRecordInstanceEntity, String> {
    @Getter
    private final LocalCarrierUsageRecordInstanceService service;

    @PostMapping("/no-auth")
    @SaveAction
    @Operation(
            summary = "新增单个数据,并返回新增后的数据."
    )
    @Authorize(ignore = true)
    public Mono<SaveResult> addOverride(@RequestBody Flux<CarrierUsageRecordInstanceEntity> payload) {
        return this.save(payload);
    }
}
